<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var checkRecord = function (s) {
			    let absentCount = 0;
			    let lateCount = 0;
			    for (let i = 0; i < s.length; i++) {
			        switch (s[i]) {
			        case 'P':
			            lateCount = 0;
			            break;
			        case 'L':
			            lateCount++;
			            if (lateCount == 3) {
			                return false;
			            }
			            break;
			        case 'A':
			            lateCount = 0;
			            absentCount++;
			            if (absentCount == 2) {
			                return false;
			            }
			            break;
			        }
			    }
			    return true;
			};
			console.log(checkRecord("PPALLP"));
		</script>
	</body>
</html>
